<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <script>

        // 延迟函数
        var throttle = function (func , interval) {
                var __self = func;
                var timer;
                var firstTime = true;

                return function() {
                    var _me = this,
                    args = arguments;

                    if(firstTime) {
                        __self.apply(_me , args)
                         firstTime = false
                         return;
                    }

                    if(timer) {
                        return false;
                    }

                    timer = setTimeout(() => {
                        clearTimeout(timer);
                        timer = null;
                        __self.apply(_me , args);
                    }, interval || 500);
                }
        }

        function trigger () {
            console.log("触发函数---");
        }

        window.onresize = throttle(trigger,1000)
    </script>
</body>
</html>